Skip to content

Conversation

@roomote
Copy link

@roomote roomote bot commented Oct 26, 2025

This PR addresses Issue #8832 by implementing comprehensive telemetry tracking for task terminations.

Summary

Adds telemetry tracking to understand user behavior patterns when terminating tasks, specifically distinguishing between:

  • Course corrections (single click - user wants to modify approach)
  • Task abandonment (multiple clicks - user gives up)
  • Mid-task guidance (termination during streaming - user needs help)

Implementation Details

New Telemetry Events

  • TASK_TERMINATED: General termination event with contextual data
  • TASK_CORRECTED: First termination attempt (course correction)
  • TASK_ABANDONED: Multiple termination attempts (abandonment)

Changes Made

  1. Added telemetry event types (packages/types/src/telemetry.ts)

    • Defined new event schemas with Zod validation
    • Captures task metadata including elapsed time, task type, and termination context
  2. Implemented capture methods (packages/telemetry/src/TelemetryService.ts)

    • captureTaskTerminated(): Records general termination with context
    • captureTaskCorrected(): Tracks single-click course corrections
    • captureTaskAbandoned(): Tracks multi-click abandonments
  3. Enhanced ClineProvider (src/core/webview/ClineProvider.ts)

    • Added telemetry capture logic in cancelTask() method
    • Classifies user intent based on click count and task state
    • Tracks elapsed time from task start to termination
  4. Added frontend click tracking (webview-ui/src/components/chat/ChatView.tsx)

    • Tracks termination click count in component state
    • Passes click count through message pipeline to backend
  5. Updated message interfaces (src/shared/WebviewMessage.ts, src/core/webview/webviewMessageHandler.ts)

    • Added optional clickCount parameter for termination tracking
    • Maintains backward compatibility

Key Features

  • Intent Classification: Automatically determines user intent based on:
    • Click count (first vs multiple)
    • Task state (streaming vs waiting)
    • Task type (ask vs execution)
  • Rich Context Capture: Records:
    • Elapsed time from task start
    • Current task stage (streaming/waiting/asking)
    • Termination source (ui/api/error)
    • Task metadata (type, model, mode)
  • Privacy-Focused: Only captures behavioral metrics, no PII or sensitive data

Testing

  • ✅ TypeScript compilation passes for both src and webview-ui
  • ✅ No type errors introduced
  • ✅ ESLint checks pass with no warnings
  • ✅ Maintains backward compatibility with optional parameters

Related Issue

Closes #8832

Feedback and suggestions are welcome!


Important

Add telemetry tracking for task terminations, classifying user intent based on click count and task state, with new events and frontend-backend integration.

  • Telemetry Events:
    • Add TASK_TERMINATED, TASK_CORRECTED, TASK_ABANDONED events in telemetry.ts.
    • Capture task metadata: elapsed time, task type, termination context.
  • Capture Methods:
    • Implement captureTaskTerminated(), captureTaskCorrected(), captureTaskAbandoned() in TelemetryService.ts.
  • ClineProvider Enhancements:
    • Update cancelTask() in ClineProvider.ts to track termination click count and classify user intent.
  • Frontend Tracking:
    • Track termination click count in ChatView.tsx.
    • Pass click count to backend via WebviewMessage.ts.
  • Message Interfaces:
    • Add clickCount parameter in WebviewMessage.ts for termination tracking.

This description was created by Ellipsis for a15d43c. You can customize this summary. It will automatically update as commits are pushed.

- Fixes ESLint react-hooks/exhaustive-deps warning
- Ensures callback properly updates when termination click count changes
@roomote roomote bot requested review from cte, jr and mrubens as code owners October 26, 2025 03:57
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 26, 2025
@roomote
Copy link
Author

roomote bot commented Oct 26, 2025

Code Review Summary

I've reviewed the telemetry tracking implementation for task terminations. The changes look solid overall with proper event schemas, telemetry capture methods, and intent classification logic.

Issues Found

  • Remove unused variables taskHistory and currentTaskItem in ClineProvider.ts (lines 2605-2606)

Review Notes

The implementation successfully:

  • ✅ Adds proper telemetry event types with Zod validation
  • ✅ Implements intent classification based on click count and task state
  • ✅ Maintains backward compatibility with optional parameters
  • ✅ Tracks termination click count through the message pipeline
  • ✅ Captures rich context including elapsed time and task state

Follow Along on Roo Code Cloud


const trimmedInput = text?.trim()

if (isStreaming) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding an inline comment to explain that the first cancel click is interpreted as a course correction, while subsequent clicks indicate task abandonment.

Comment on lines +2605 to +2606
const taskHistory = this.getGlobalState("taskHistory") ?? []
const currentTaskItem = taskHistory.find((item: HistoryItem) => item.id === task.taskId)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variables taskHistory and currentTaskItem are declared but never used in the telemetry tracking logic. These can be removed to clean up the code.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Oct 26, 2025
Copy link
Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review complete. Found 1 minor issue to address (unused variables).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Telemetry: Including Task Terminations, Course-Corrections, and User Cancelations

2 participants